function IntervalInitAssistant() {
	/*
	 * this is the creator function for your scene assistant object. It will be
	 * passed all the additional parameters (after the scene name) that were
	 * passed to pushScene. The reference to the scene controller
	 * (this.controller) has not be established yet, so any initialization that
	 * needs the scene controller should be done in the setup function below.
	 */
}

IntervalInitAssistant.prototype.setup = function() {
	/*
	 * this function is for setup tasks that have to happen when the scene is
	 * first created
	 */
		
	// Set the default Values
	this.defaultCookie = new Mojo.Model.Cookie("Music-Quiz-Int-Settings");
	// this.controller.stageController.setWindowOrientation('free');

	/*
	 * quizStats = { qSize : qNum, qTime : tNum, qSound : tSound, qClef :
	 * cCleff, qSharp : tSharp, showStaff : sCleff, nType : tNoteType, qAnswers : [] };
	 * 
	 */
	intStats = this.defaultCookie.get();
	Mojo.Log.info("Got Cookie:" + intStats);

	// Set Defaults
	qNumDefault=10;
	tSoundDefault=1;
	tChordDefault=2;
	
	this.myListModel = {
		        items: [{checked: false, itemText: 'Minor Second', iID: 'm2'}, 
		                {checked: false, itemText: 'Major Second', iID: 'M2'},
		                {checked: false, itemText: 'Minor Third', iID: 'm3'},
		                {checked: true, itemText: 'Major Third', iID: 'M3'},
		                {checked: false, itemText: 'Perfect Fourth', iID: 'P4'},
		                {checked: false, itemText: 'Diminished Fifth', iID: 'a4'},
		                {checked: true, itemText: 'Perfect Fifth', iID: 'P5'},
		                {checked: false, itemText: 'Minor Sixth', iID: 'm6'},
		                {checked: false, itemText: 'Major Sixth', iID: 'M6'},
		                {checked: false, itemText: 'Minor Seventh', iID: 'm7'},
		                {checked: false, itemText: 'Major Seventh', iID: 'M7'},
		                {checked: true, itemText: 'Octave', iID: 'P8'},]   
		   }
	// Overwrite Defaults with cookie.
	
	if (intStats) {
		Mojo.Log.info("found cookie");
		qNumDefault = intStats.qSize;
		tChordDefault = intStats.tChord;
		this.myListModel = intStats.selInt;
		
		bSound = intStats.qSound;
		bShowClef = intStats.showStaff;

		if (bSound == true && bShowClef == true) {
			Mojo.Log.info("cNote = 1");
			tSoundDefault = 1;
		} else if (bSound == false && bShowClef == true) {
			Mojo.Log.info("cNote = 2");
			tSoundDefault = 2;
		} else {
			Mojo.Log.info("cNote = 3");
			tSoundDefault = 3;
		}

	}
	
	
	
	/* add event handlers to listen to events from widgets */	
	this.controller.setupWidget("qNum", this.attributes = {
			label : ' ',
			modelProperty : 'value',
			min : 1,
			max : 20
		}, this.qNumModel = {
			value : qNumDefault
		});
	
	this.controller.setupWidget("tSound", this.attributes = {
			choices : [ {
				label : "Clef w/Sound",
				value : 1
			}, {
				label : "Clef wo/Sound",
				value : 2
			}, {
				label : "Sound Only",
				value : 3
			},

			]
		}, this.tSoundModel = {
			value : tSoundDefault,
			disabled : false
		});
	
	//List Box for Chord or Single Note Playing
	this.controller.setupWidget("tChord", this.attributes = {
			choices : [ {
				label : "Chord",
				value : 1
			}, {
				label : "Single Notes",
				value : 2
			},

			]
		}, this.tChordModel = {
			value : tChordDefault,
			disabled : false
		});
	
	// List Checkbox
	 this.myCheckboxAttribs = {
		        modelProperty: 'checked',
		        // more attribs here...
		   }
		 
		   this.myListAttribs = {
			 itemTemplate: 'IntervalInit/listRowTemplate',
		   }
		 

		 
	 this.controller.setupWidget('mylist', this.myListAttribs, this.myListModel);
	 this.controller.setupWidget('itemCheck', this.myCheckboxAttribs);
	 
	//Back Widget
		if(myApp.isTouchPad()){

			 var menuModel = {

			             visible: true,
			             items: [ 
			                    { icon: "back", command: "goBack"}
			             ]
			         }; 

			     this.controller.setupWidget(Mojo.Menu.commandMenu,
			         this.attributes = {
			             spacerHeight: 0,
			             menuClass: 'no-fade'
			         },
			         menuModel
			     );   

			}

	// Button Control
	this.controller.setupWidget("bDone", this.attributes = {}, this.model = {
			label : "Start",
			disabled : false
		});

		Mojo.Event.listen(this.controller.get("bDone"), Mojo.Event.tap,
				this.handleButtonTap.bind(this));
		
};


IntervalInitAssistant.prototype.handleButtonTap = function(event) {
	// Get Values
	Mojo.Log.info("Entering IntervalInit::handleButtonTap");
	qNum = this.qNumModel.value;
	tIntervals = [];
	// Handle TSound
	if (this.tSoundModel.value == 1) {
		tSound = true;
		sCleff = true;
	} else if (this.tSoundModel.value == 2) {
		tSound = false;
		sCleff = true;
	} else {
		tSound = true;
		sCleff = false;
	}
	
	for(z=0;z<this.myListModel.items.length;z++)
		Mojo.Log.info("Interval: " + this.myListModel.items[z].iID + " Item Value:" + this.myListModel.items[z].checked);
	
	intStats = {
		qSize: qNum,
		qSound: tSound,
		showStaff:sCleff,
		selInt: this.myListModel,
		qClef:1,
		tChord:this.tChordModel.value,
		qAnswers: []
	};

	this.defaultCookie.put(intStats);

	Mojo.Controller.stageController.pushScene("MainInterval", intStats);
	
Mojo.Log.info("Exiting IntervalInit::handleButton");
};
IntervalInitAssistant.prototype.activate = function(event) {
	/*
	 * put in event handlers here that should only be in effect when this scene
	 * is active. For example, key handlers that are observing the document
	 */
};

IntervalInitAssistant.prototype.deactivate = function(event) {
	/*
	 * remove any event handlers you added in activate and do any other cleanup
	 * that should happen before this scene is popped or another scene is pushed
	 * on top
	 */
};

IntervalInitAssistant.prototype.cleanup = function(event) {
	/*
	 * this function should do any cleanup needed before the scene is destroyed
	 * as a result of being popped off the scene stack
	 */
};
